package com.gf.controller.user;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;

/*
 *注销用户登录状态的servlet
 * */

@WebServlet(name = "UserExitServlet",urlPatterns = "/exit")
public class UserExitServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //清除用户session中的id编号id姓名和购物车信息
        request.getSession().setAttribute("userid",null);
        request.getSession().setAttribute("username",null);
        request.getSession().setAttribute("shoppingcart",null);
        //重定向到登陆页面
        response.sendRedirect(request.getContextPath()+"/login.jsp");

    }
}
